/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package vn.com.fis.portal.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import vn.com.fis.portal.model.CategoryEntry;
import vn.com.fis.portal.model.CategoryEntryModel;
import vn.com.fis.portal.model.CategoryEntrySoap;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.List;

/**
 * The base model implementation for the CategoryEntry service. Represents a row in the &quot;tbl_category&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link vn.com.fis.portal.model.CategoryEntryModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link CategoryEntryImpl}.
 * </p>
 *
 * @author loind
 * @see CategoryEntryImpl
 * @see vn.com.fis.portal.model.CategoryEntry
 * @see vn.com.fis.portal.model.CategoryEntryModel
 * @generated
 */
@JSON(strict = true)
public class CategoryEntryModelImpl extends BaseModelImpl<CategoryEntry>
	implements CategoryEntryModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a category entry model instance should use the {@link vn.com.fis.portal.model.CategoryEntry} interface instead.
	 */
	public static final String TABLE_NAME = "tbl_category";
	public static final Object[][] TABLE_COLUMNS = {
			{ "categoryId", Types.BIGINT },
			{ "categoryName", Types.VARCHAR },
			{ "description", Types.VARCHAR },
			{ "status", Types.INTEGER }
		};
	public static final String TABLE_SQL_CREATE = "create table tbl_category (categoryId LONG not null primary key,categoryName VARCHAR(75) null,description VARCHAR(75) null,status INTEGER)";
	public static final String TABLE_SQL_DROP = "drop table tbl_category";
	public static final String ORDER_BY_JPQL = " ORDER BY categoryEntry.categoryName ASC";
	public static final String ORDER_BY_SQL = " ORDER BY tbl_category.categoryName ASC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.vn.com.fis.portal.model.CategoryEntry"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.vn.com.fis.portal.model.CategoryEntry"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.vn.com.fis.portal.model.CategoryEntry"),
			true);
	public static long CATEGORYNAME_COLUMN_BITMASK = 1L;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static CategoryEntry toModel(CategoryEntrySoap soapModel) {
		CategoryEntry model = new CategoryEntryImpl();

		model.setCategoryId(soapModel.getCategoryId());
		model.setCategoryName(soapModel.getCategoryName());
		model.setDescription(soapModel.getDescription());
		model.setStatus(soapModel.getStatus());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<CategoryEntry> toModels(CategoryEntrySoap[] soapModels) {
		List<CategoryEntry> models = new ArrayList<CategoryEntry>(soapModels.length);

		for (CategoryEntrySoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final String MAPPING_TABLE_TBL_CATEGORY_VIDEO_NAME = "tbl_category_video";
	public static final Object[][] MAPPING_TABLE_TBL_CATEGORY_VIDEO_COLUMNS = {
			{ "videoId", Types.BIGINT },
			{ "categoryId", Types.BIGINT }
		};
	public static final String MAPPING_TABLE_TBL_CATEGORY_VIDEO_SQL_CREATE = "create table tbl_category_video (videoId LONG not null,categoryId LONG not null,primary key (videoId, categoryId))";
	public static final boolean FINDER_CACHE_ENABLED_TBL_CATEGORY_VIDEO = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.tbl_category_video"), true);
	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.vn.com.fis.portal.model.CategoryEntry"));

	public CategoryEntryModelImpl() {
	}

	public long getPrimaryKey() {
		return _categoryId;
	}

	public void setPrimaryKey(long primaryKey) {
		setCategoryId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_categoryId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return CategoryEntry.class;
	}

	public String getModelClassName() {
		return CategoryEntry.class.getName();
	}

	@JSON
	public long getCategoryId() {
		return _categoryId;
	}

	public void setCategoryId(long categoryId) {
		_categoryId = categoryId;
	}

	@JSON
	public String getCategoryName() {
		if (_categoryName == null) {
			return StringPool.BLANK;
		}
		else {
			return _categoryName;
		}
	}

	public void setCategoryName(String categoryName) {
		_columnBitmask = -1L;

		if (_originalCategoryName == null) {
			_originalCategoryName = _categoryName;
		}

		_categoryName = categoryName;
	}

	public String getOriginalCategoryName() {
		return GetterUtil.getString(_originalCategoryName);
	}

	@JSON
	public String getDescription() {
		if (_description == null) {
			return StringPool.BLANK;
		}
		else {
			return _description;
		}
	}

	public void setDescription(String description) {
		_description = description;
	}

	@JSON
	public int getStatus() {
		return _status;
	}

	public void setStatus(int status) {
		_status = status;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public CategoryEntry toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (CategoryEntry)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
					CategoryEntry.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	@Override
	public Object clone() {
		CategoryEntryImpl categoryEntryImpl = new CategoryEntryImpl();

		categoryEntryImpl.setCategoryId(getCategoryId());
		categoryEntryImpl.setCategoryName(getCategoryName());
		categoryEntryImpl.setDescription(getDescription());
		categoryEntryImpl.setStatus(getStatus());

		categoryEntryImpl.resetOriginalValues();

		return categoryEntryImpl;
	}

	public int compareTo(CategoryEntry categoryEntry) {
		int value = 0;

		value = getCategoryName().compareTo(categoryEntry.getCategoryName());

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		CategoryEntry categoryEntry = null;

		try {
			categoryEntry = (CategoryEntry)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = categoryEntry.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		CategoryEntryModelImpl categoryEntryModelImpl = this;

		categoryEntryModelImpl._originalCategoryName = categoryEntryModelImpl._categoryName;

		categoryEntryModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<CategoryEntry> toCacheModel() {
		CategoryEntryCacheModel categoryEntryCacheModel = new CategoryEntryCacheModel();

		categoryEntryCacheModel.categoryId = getCategoryId();

		categoryEntryCacheModel.categoryName = getCategoryName();

		String categoryName = categoryEntryCacheModel.categoryName;

		if ((categoryName != null) && (categoryName.length() == 0)) {
			categoryEntryCacheModel.categoryName = null;
		}

		categoryEntryCacheModel.description = getDescription();

		String description = categoryEntryCacheModel.description;

		if ((description != null) && (description.length() == 0)) {
			categoryEntryCacheModel.description = null;
		}

		categoryEntryCacheModel.status = getStatus();

		return categoryEntryCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(9);

		sb.append("{categoryId=");
		sb.append(getCategoryId());
		sb.append(", categoryName=");
		sb.append(getCategoryName());
		sb.append(", description=");
		sb.append(getDescription());
		sb.append(", status=");
		sb.append(getStatus());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(16);

		sb.append("<model><model-name>");
		sb.append("vn.com.fis.portal.model.CategoryEntry");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>categoryId</column-name><column-value><![CDATA[");
		sb.append(getCategoryId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>categoryName</column-name><column-value><![CDATA[");
		sb.append(getCategoryName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>description</column-name><column-value><![CDATA[");
		sb.append(getDescription());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>status</column-name><column-value><![CDATA[");
		sb.append(getStatus());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = CategoryEntry.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			CategoryEntry.class
		};
	private long _categoryId;
	private String _categoryName;
	private String _originalCategoryName;
	private String _description;
	private int _status;
	private transient ExpandoBridge _expandoBridge;
	private long _columnBitmask;
	private CategoryEntry _escapedModelProxy;
}